package test2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;

import test2.pojo.Se;
import utils.WishColumn;
import utils.WishExcel;
import utils.WishExcelFunction;
import utils.WishModule;
import utils.handlers.RowBoldWriteHandler;

// 单个sheet和单个数据源
public class Test3
{
	public static List<Se> getDatas(int max)
	{
		// 数据
		List<Se> datas = new ArrayList<>();

		for (int i = 0; i < max; i++)
		{
			Se se = new Se();
			se.setName("姓名" + i);
			se.setAge(19 + i);
			datas.add(se);
		}
		return datas;
	}

	public static void main(String[] args)
	{
		// 数据
		// 头部

		WishColumn<Se> header1 = new WishColumn<Se>("姓名",x->x.getName());

		try (ExcelWriter excelWriter = WishExcel.getExcelWriter("test.xlsx"))
		{
			WriteSheet writeSheet = EasyExcel.writerSheet().build();
			
			{
				WishModule<?> module1 = new WishModule<>();
				module1.setTableHeaders(Arrays.asList(new WishColumn<>("整体名称你分析", Arrays.asList(header1))));
				module1.setDatasSuppliers(Arrays.asList(() -> getDatas(2)));
				RowBoldWriteHandler r = new RowBoldWriteHandler(1);
				module1.addWriteHandler(r);
				
				
				
				WishExcel.write(excelWriter, module1);
			}
			
			{
				WishModule<?> module2 = new WishModule<>();
				module2.setTableHeaders(Arrays.asList(new WishColumn<>("整体名称你分析", Arrays.asList(header1))));
				module2.setDatasSuppliers(Arrays.asList(() -> getDatas(3)));
				RowBoldWriteHandler r = new RowBoldWriteHandler(2);
				module2.addWriteHandler(r);
				WishExcel.write(excelWriter, module2);
			}
			
			
			{
				WishModule<?> module = new WishModule<>();
				module.setTableHeaders(Arrays.asList(new WishColumn<>("整体名称你分析", Arrays.asList(header1))));
				module.setDatasSuppliers(Arrays.asList(() -> getDatas(4)));
				RowBoldWriteHandler r = new RowBoldWriteHandler(3);
				module.addWriteHandler(r);
				WishExcel.write(excelWriter, module);
			}
		}

	}
}
